home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 2190 < prev    next >
Encoding:
Internet Message Format  |  1996-08-06  |  3.4 KB

  1. Path: BIX.com!magma
  2. From: magma@BIX.com (magma on BIX)
  3. Newsgroups: comp.lang.c++
  4. Subject: Re: Help with Cedit view !
  5. Date: 16 Jan 96 11:48:06 GMT
  6. Organization: Delphi Internet Services Corporation
  7. Message-ID: <magma.821792886@BIX.com>
  8. References: <4de4af$s71@server-b.cs.interbusiness.it>
  9. NNTP-Posting-Host: bix.com
  10.  
  11. Softec@system.abacom.it (Softec@system.abacom.it) writes:
  12.  
  13. >I'm developing an editor using the Microsoft Visual C++ and the MFC.
  14. >My editor has the following features:
  15. >    1. Show the content of a ASCII file.
  16. >    2. Change the text color and the background color of a line when a particular
  17. >condition occours (same as when I set a breakpoint in the Visual C++ editor)
  18.  
  19. >I tried to derivated the CEditView class and I loaded the file using the following code:
  20.  
  21. >    CEdit& edit = GetEditCtrl();        // get a reference to the CEdit control
  22. >    CFile f;                // used by the edit view
  23.  
  24. >    if(!f.Open(filename, CFile::modeRead | CFile::typeBinary))
  25. >        {
  26. >        AfxMessageBox("File no found");
  27. >        return 0;
  28. >        }
  29. >    DWORD len = f.GetLength();
  30. >    HLOCAL hBuff = LocalAlloc(LMEM_MOVEABLE,len+1);
  31. >    LPSTR = (LPSTR)LocalLock(hBuff);
  32. >    f.Read(pbuff,len);
  33. >    f.Close();
  34. >    pbuff[len]=NULL;
  35. >    edit.SetWindowText(pbuff);
  36. >    edit.SetReadOnly(TRUE);        // Read only
  37. >    LocalUnlock(hBuff);
  38. >    LocalFree(hBuff);    
  39. >    return 0;
  40.  
  41.  
  42. >But now I don't know how to change the color of a line.
  43. >Where is somebody that can help me ?
  44.  
  45. >Thank you in advance
  46. >    Piero Poletto
  47.  
  48.  
  49. Hello,
  50.  
  51. What you are trying to do with a CEditView is not very easy, especially
  52. since the CEditView class uses the standard Windows edit control, and
  53. therefore, has no provisions for coloring individual chunks of text.
  54. There are several things you can do :
  55.  
  56. 1) Write your own edit control.
  57.  
  58. 2) Use the new Microsoft Win95 RICHED control.
  59.  
  60. 3) Use a third party edit control like the Magma Editor. I have
  61. enclosed a "canned" reply which is sent to people who need features
  62. like syntax highlighting, etc. By the way, the Magma Editor DLl has been
  63. used to provide the edit buffer for debuggers.
  64.  
  65. Regards,
  66.  
  67. Marc Adler
  68.  
  69. -------------------
  70.  
  71. Hello,
  72.  
  73. In your posting, you mentioned that you were looking for a Windows
  74. editing DLL which could do syntax highlighting.
  75.  
  76. The MAGMA Editor DLL/VBX for Win16/Win32 can help you out.
  77. It has an ownerdrawn-line style, much like Windows' ownerdrawn listboxes
  78. and menus. When you give the edit control the ES_OWNERDRAW style, your
  79. application is sent notification messages when each line needs to be
  80. drawn. You can draw the line yourself, or you can let the editor
  81. itself draw the line.
  82.  
  83. Using ownerdrawn lines, many developers who use the Magma Editor DLL
  84. have implemented syntax highlighting within their apps. In fact, the
  85. MEWIN programmer's editor sample which comes with the Magma Editor
  86. has code to do some simple "C"-language syntax highlighting.
  87.  
  88. The Magma Editor DLL has a lot of other features which make it very
  89. useful for building IDEs or custom language editors. You can think of
  90. it as a 'BRIEF-in-a-DLL'.
  91.  
  92. You can use the editor with any language or environment which supports
  93. loading DLLs. We also have drop-in replacement classes for MFC, zApp,
  94. OWL, VB, and PASCAL.
  95.  
  96. For more info, you can visit the WWW page http://www.uno.com.
  97. You can download a fully functional 'lite' version from the WWW page or
  98. you can FTP it from ftp.uu.net, directory /vendor/uno. Look for MAGMAED.ZIP. 
  99. There are also files for the drop-in replacement classes.
  100.  
  101. Regards,
  102.  
  103. Marc Adler
  104. Magma Systems
  105.  
  106.  
  107.